#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Node
{
public:
    int val;
    vector<Node *> children;

    Node() {}

    Node(int _val)
    {
        val = _val;
    }

    Node(int _val, vector<Node *> _children)
    {
        val = _val;
        children = _children;
    }
};
class Solution
{
public:
    vector<int> ans;
    vector<int> postorder(Node *root)
    {
        if (root == NULL)
            return {};
        if ((root->children).size() > 0)
        {
            for (auto cnode : root->children)
            {
                if (cnode != NULL)
                    postorder(cnode);
            }
        }
        ans.push_back(root->val);
        return ans;
    }
};
int main()
{
    Solution *s = new Solution();
    vector<int> ans;
    // vector<Node *> children{new Node(1), NULL, new Node(3), new Node(2), new Node(4), NULL, new Node(5), new Node(6)};
    Node *root = new Node(1);
    ans = s->postorder(root);
    for (int i = 0; i < ans.size(); i++)
    {
        cout << ans[i] << endl;
    }
    return 0;
}